// // 定义请求的URL
// const url = 'https://webapi.115.com/files/batch_rename';

// // 定义要发送的数据
// const formData = new FormData();
// const queryString = encodeURIComponent('files_new_name[3047990119656062567]: [Thz----]arm-557.mp4');

// // 设置请求的选项
// const options = {
//   method: 'POST',
//     headers: {
//       'Content-Type': 'application/x-www-form-urlencoded',
//       'Cookie': '115_lang=zh; USERSESSIONID=10be6e9606d80c047d308f9d7a2474f37ecc53caf4fd99cb9c47e407d2c8ade8; UID=26116844_A1_1734583776; CID=e18fad0d6f5a3d482798c898215b4710; SEID=30c189a5e5238f1a6124f3419b1903885a17f7e84172eb95387dc8b653a7bd996fbc75e2a308d2faf3ac88ebc5815723bf725e225828e492cb22760d; KID=4cbdbe38410278c3bd57fd1b8e863c05;PHPSESSID=816bsjcipcf0teevcnakk589so; acw_tc=784e2c9e17347068690013797e69eaf9395865f6eff1dca0ad8150c9b3f810'
//     },
//     body: queryString
// };

// // 发送请求
// fetch(url, options)
//   .then(response => {
//     if (response.ok) {
//       return response.text;
//     }
//     throw new Error('Network response was not ok.');
//   })
//   .then(responseData => {
//     console.log('Request succeeded with response:', responseData);
//   })
//   .catch(error => {
//     console.error('Request failed:', error);
//   });

function getQueryParam(param) {
    const urlParams = new URLSearchParams(window.location.search);
    return urlParams.get(param);
}

function rename_115(){
    // 使用 prompt() 获取用户输入
    var newFileName = prompt("请输入新的文件名：");
    if (!newFileName) {
        alert("用户输入为空...");
        return
    }

    let pickcode = getQueryParam('pickcode');
    if (!pickcode){
        alert("无法获取 pickcode...");
        return;
    }
    let url = 'http://localhost:10168/rename115?pickcode=' + pickcode+ '&newfname=' + newFileName;
    // 使用 fetch 调用接口
    fetch(url)
        .then(response => {
            if (!response.ok) {
                throw new Error('Network response was not ok');
            }
            console.log('文件名修改成功!。。。:', data);
            // 你可以在这里处理接口返回的数据
            alert('文件名修改成功!。。。');
        })
        .catch(error => {
            console.error('文件名修改成功!。。。:', error);
            alert('文件名修改失败。。。');
        });
}

rename_115();